// 导入NestJS的模块
import { Module } from '@nestjs/common';
// 导入应用主控制器 控制器一般用来定义路径，定义什么方法访问什么路径进行怎么处理
import { AppController } from './app.controller';
// 导入主服务 服务里主要是一些业务方法，用来对数据进行处理和加载
import { AppService } from './app.service';
import { MongooseModule } from '@nestjs/mongoose';
import { BannerSchema } from './schemas/banner.schema';
import { NavigationMenuSchema } from './schemas/navigation_menu.schema';
import { BannerController } from './controllers/banner/banner.controller';
import { BannerService } from './services/banner/banner.service';
import { NavigationMenuService } from './services/navigation_menu/navigation_menu.service';
import { NavigationMenuController } from './controllers/navigation_menu/navigation_menu.controller';
import { CategorySchema } from './schemas/category.schema';
import { CategoryService } from './services/category/category.service';
import { CategoryController } from './controllers/category/category.controller';
import { ProductSchema } from './schemas/product.schema';
import { ProductService } from './services/product/product.service';
import { ProductController } from './controllers/product/product.controller';
// 使用@module装饰器定义模块，配置它的依赖和提供的服务
@Module({
  imports: [
    // 可以导入别的模块
    // 配置mongoose连接到本地的Mongodb数据库，数据库的名字叫vmall
    MongooseModule.forRoot('mongodb://127.0.0.1/vmall'),
    // 配置mongoose的模型，这里先定义了Banner的模型
    MongooseModule.forFeature([
      {
        name: 'Banner',
        schema: BannerSchema,
      },
      {
        name: 'NavigationMenu',
        schema: NavigationMenuSchema,
      },
      {
        name: 'Category',
        schema: CategorySchema,
      },
      {
        name: 'Product',
        schema: ProductSchema,
      },
    ]),
  ],
  controllers: [
    AppController,
    BannerController,
    NavigationMenuController,
    CategoryController,
    ProductController,
  ], // 指定该模块使用的控制器
  providers: [
    AppService,
    BannerService,
    NavigationMenuService,
    CategoryService,
    ProductService,
  ], // 指定该模块使用的服务提供者
})
export class AppModule {}
// 导出模块类，以供Nest应用工厂创建实例的时候使用
